package com.ruoyi.finance.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.finance.domain.CommissionDeliverySituation;
import com.ruoyi.finance.service.ICommissionDeliverySituationService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 提成发货情况Controller
 *
 * @author admin
 * @date 2023-10-19
 */
@RestController
@RequestMapping("/deliverySituation")
@RequiredArgsConstructor
public class CommissionDeliverySituationController extends BaseController {
    @Autowired
    private ICommissionDeliverySituationService commissionDeliverySituationService;

    /**
     * 查询提成发货情况列表
     */
    @SaCheckPermission("'finance:deliverySituation:list")
    @GetMapping("/list")
    public TableDataInfo list(CommissionDeliverySituation commissionDeliverySituation) {
        List<CommissionDeliverySituation> list = commissionDeliverySituationService.selectCommissionDeliverySituationList(commissionDeliverySituation);
        return TableDataInfo.build(list);
    }

    ///**
    // * 导出提成发货情况列表
    // */
    //@SaCheckPermission("'finance:deliverySituation:export")
    //@Log(title = "提成发货情况", businessType = BusinessType.EXPORT)
    //@GetMapping("/export")
    //public AjaxResult export(CommissionDeliverySituation commissionDeliverySituation) {
    //    List<CommissionDeliverySituation> list = commissionDeliverySituationService.selectCommissionDeliverySituationList(commissionDeliverySituation);
    //    ExcelUtil<CommissionDeliverySituation> util = new ExcelUtil<CommissionDeliverySituation>(CommissionDeliverySituation.class);
    //    return util.exportExcel(list, "提成发货情况数据");
    //}
    //
    ///**
    // * 获取提成发货情况详细信息
    // */
    //@SaCheckPermission("'finance:deliverySituation:query")
    //@GetMapping(value = "/{id}")
    //public AjaxResult getInfo(@PathVariable("id") Long id) {
    //    return AjaxResult.success(commissionDeliverySituationService.selectCommissionDeliverySituationById(id));
    //}

    /**
     * 新增提成发货情况
     */
    @SaCheckPermission("'finance:deliverySituation:add")
    @Log(title = "提成发货情况", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Void> add(@RequestBody CommissionDeliverySituation commissionDeliverySituation) {
        return toAjaxR(commissionDeliverySituationService.insertCommissionDeliverySituation(commissionDeliverySituation));
    }

    /**
     * 修改提成发货情况
     */
    @SaCheckPermission("'finance:deliverySituation:edit")
    @Log(title = "提成发货情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Void> edit(@RequestBody CommissionDeliverySituation commissionDeliverySituation) {
        return toAjaxR(commissionDeliverySituationService.updateCommissionDeliverySituation(commissionDeliverySituation));
    }

    /**
     * 删除提成发货情况
     */
    @SaCheckPermission("'finance:deliverySituation:remove")
    @Log(title = "提成发货情况", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@PathVariable Long[] ids) {
        return toAjaxR(commissionDeliverySituationService.deleteCommissionDeliverySituationByIds(ids));
    }
}
